/* Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "zobjects_gtk.h"

ZlangInvokeFunction ZlangInvokeFunction_guiaboutdialog_ModalOpenDialog_guiwindow_string_string_string_string_int_string_string;
int ZlangInvokeFunction_guiaboutdialog_ModalOpenDialog_guiwindow_string_string_string_string_int_string_string( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*in2 = GetInputParameterInLocalObjectStack(rt,2) ;
	struct ZlangObject				*in3 = GetInputParameterInLocalObjectStack(rt,3) ;
	struct ZlangObject				*in4 = GetInputParameterInLocalObjectStack(rt,4) ;
	struct ZlangObject				*in5 = GetInputParameterInLocalObjectStack(rt,5) ;
	struct ZlangObject				*in6 = GetInputParameterInLocalObjectStack(rt,6) ;
	struct ZlangObject				*in7 = GetInputParameterInLocalObjectStack(rt,7) ;
	struct ZlangObject				*in8 = GetInputParameterInLocalObjectStack(rt,8) ;
	struct ZlangDirectProperty_guiwindow		*guiwindow_direct_prop = GetObjectDirectProperty(in1) ;
	struct ZlangDirectProperty_guiwidget_common	*guiwindow_common = (struct ZlangDirectProperty_guiwidget_common *)guiwindow_direct_prop ;
	GFile						*logo_file = NULL ;
	GdkTexture					*logo = NULL ;
	GtkWidget					*about_dialog = NULL ;
	char						*logo_pathfilename = NULL ;
	char						*program_name = NULL ;
	char						*version = NULL ;
	char						*copyright = NULL ;
	char						*website = NULL ;
	int						license ;
	const char					*authors[2] = { NULL , NULL } ;
	
	CallRuntimeFunction_string_GetStringValue( rt , in2 , & logo_pathfilename , NULL );
	CallRuntimeFunction_string_GetStringValue( rt , in3 , & program_name , NULL );
	CallRuntimeFunction_string_GetStringValue( rt , in4 , & version , NULL );
	CallRuntimeFunction_string_GetStringValue( rt , in5 , & copyright , NULL );
	CallRuntimeFunction_int_GetIntValue( rt , in6 , & license );
	CallRuntimeFunction_string_GetStringValue( rt , in7 , & website , NULL );
	CallRuntimeFunction_string_GetStringValue( rt , in8 , (char **) & (authors[0]) , NULL );

	about_dialog = gtk_about_dialog_new() ;
	gtk_window_set_transient_for( GTK_WINDOW(about_dialog), GTK_WINDOW(guiwindow_common->gtk_widget) );
	if( logo_pathfilename && logo_pathfilename[0] )
	{
		logo_file = g_file_new_for_path( logo_pathfilename ) ;
		logo = gdk_texture_new_from_file( logo_file , NULL ) ;
		g_object_unref( logo_file );
		gtk_about_dialog_set_logo( GTK_ABOUT_DIALOG(about_dialog) , GDK_PAINTABLE(logo) );
	}
	if( program_name && program_name[0] )
	{
		gtk_about_dialog_set_program_name( GTK_ABOUT_DIALOG(about_dialog) , program_name );
	}
	if( version && version[0] )
	{
		gtk_about_dialog_set_version( GTK_ABOUT_DIALOG(about_dialog) , version );
	}
	if( authors[0] )
	{
		gtk_about_dialog_set_authors( GTK_ABOUT_DIALOG(about_dialog) , authors );
	}
	if( copyright && copyright[0] )
	{
		gtk_about_dialog_set_copyright( GTK_ABOUT_DIALOG(about_dialog) , copyright );
	}
	if( license > 0 )
	{
		gtk_about_dialog_set_license_type( GTK_ABOUT_DIALOG(about_dialog) , license );
	}
	if( website && website[0] )
	{
		gtk_about_dialog_set_website( GTK_ABOUT_DIALOG(about_dialog) , website );
	}
	if( authors[0] )
	{
		gtk_about_dialog_set_authors( GTK_ABOUT_DIALOG(about_dialog) , authors );
	}

	gtk_window_set_transient_for( GTK_WINDOW(about_dialog) , GTK_WINDOW(guiwindow_common->gtk_widget) );
	gtk_window_set_modal( GTK_WINDOW(about_dialog) , TRUE );
	
	gtk_widget_show( about_dialog );

	return 0;
}

ZlangCreateDirectPropertyFunction ZlangCreateDirectProperty_guiaboutdialog;
void *ZlangCreateDirectProperty_guiaboutdialog( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guiaboutdialog	*guiaboutdialog_prop = NULL ;
	
	guiaboutdialog_prop = (struct ZlangDirectProperty_guiaboutdialog *)ZLMALLOC( sizeof(struct ZlangDirectProperty_guiaboutdialog) ) ;
	if( guiaboutdialog_prop == NULL )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , ZLANG_ERROR_ALLOC , "alloc memory for entity" )
		return NULL;
	}
	memset( guiaboutdialog_prop , 0x00 , sizeof(struct ZlangDirectProperty_guiaboutdialog) );
	
	return guiaboutdialog_prop;
}

ZlangDestroyDirectPropertyFunction ZlangDestroyDirectProperty_guiaboutdialog;
void ZlangDestroyDirectProperty_guiaboutdialog( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guiaboutdialog	*guiaboutdialog_direct_prop = GetObjectDirectProperty(obj) ;
	
	ZLFREE( guiaboutdialog_direct_prop );
	
	return;
}

ZlangSummarizeDirectPropertySizeFunction ZlangSummarizeDirectPropertySize_guiaboutdialog;
void ZlangSummarizeDirectPropertySize_guiaboutdialog( struct ZlangRuntime *rt , struct ZlangObject *obj , size_t *summarized_obj_size , size_t *summarized_direct_prop_size )
{
	SUMMARIZE_SIZE( summarized_direct_prop_size , sizeof(struct ZlangDirectProperty_guiaboutdialog) )
	return;
}

static struct ZlangDirectFunctions direct_funcs_guiaboutdialog =
	{
		ZLANG_OBJECT_guiaboutdialog , /* char *ancestor_name */
		
		ZlangCreateDirectProperty_guiaboutdialog , /* ZlangCreateDirectPropertyFunction *create_entity_func */
		ZlangDestroyDirectProperty_guiaboutdialog , /* ZlangDestroyDirectPropertyFunction *destroy_entity_func */
		
		NULL , /* ZlangFromCharPtrFunction *from_char_ptr_func */
		NULL , /* ZlangToStringFunction *to_string_func */
		NULL , /* ZlangFromDataPtrFunction *from_data_ptr_func */
		NULL , /* ZlangGetDataPtrFunction *get_data_ptr_func */
		
		NULL , /* ZlangOperatorFunction *oper_PLUS_func */
		NULL , /* ZlangOperatorFunction *oper_MINUS_func */
		NULL , /* ZlangOperatorFunction *oper_MUL_func */
		NULL , /* ZlangOperatorFunction *oper_DIV_func */
		NULL , /* ZlangOperatorFunction *oper_MOD_func */
		
		NULL , /* ZlangUnaryOperatorFunction *unaryoper_NEGATIVE_func */
		NULL , /* ZlangUnaryOperatorFunction *unaryoper_NOT_func */
		NULL , /* ZlangUnaryOperatorFunction *unaryoper_BIT_REVERSE_func */
		NULL , /* ZlangUnaryOperatorFunction *unaryoper_PLUS_PLUS_func */
		NULL , /* ZlangUnaryOperatorFunction *unaryoper_MINUS_MINUS_func */
		
		NULL , /* ZlangCompareFunction *comp_EGUAL_func */
		NULL , /* ZlangCompareFunction *comp_NOTEGUAL_func */
		NULL , /* ZlangCompareFunction *comp_LT_func */
		NULL , /* ZlangCompareFunction *comp_LE_func */
		NULL , /* ZlangCompareFunction *comp_GT_func */
		NULL , /* ZlangCompareFunction *comp_GE_func */
		
		NULL , /* ZlangLogicFunction *logic_AND_func */
		NULL , /* ZlangLogicFunction *logic_OR_func */
		
		NULL , /* ZlangLogicFunction *bit_AND_func */
		NULL , /* ZlangLogicFunction *bit_XOR_func */
		NULL , /* ZlangLogicFunction *bit_OR_func */
		NULL , /* ZlangLogicFunction *bit_MOVELEFT_func */
		NULL , /* ZlangLogicFunction *bit_MOVERIGHT_func */
		
		ZlangSummarizeDirectPropertySize_guiaboutdialog , /* ZlangSummarizeDirectPropertySizeFunction *summarize_direct_prop_size_func */
	} ;

ZlangImportObjectFunction ZlangImportObject_guiaboutdialog;
struct ZlangObject *ZlangImportObject_guiaboutdialog( struct ZlangRuntime *rt )
{
	struct ZlangObject	*obj = NULL ;
	struct ZlangFunction	*func = NULL ;
	int			nret = 0 ;
	
	nret = ImportObject( rt , & obj , ZLANG_OBJECT_guiaboutdialog , & direct_funcs_guiaboutdialog , sizeof(struct ZlangDirectFunctions) , NULL ) ;
	if( nret )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , ZLANG_ERROR_LINK_FUNC_TO_ENTITY , "import object to global objects heap" )
		return NULL;
	}
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guiaboutdialog_ModalOpenDialog_guiwindow_string_string_string_string_int_string_string , ZLANG_OBJECT_void , "ModalOpenDialog" , ZLANG_OBJECT_guiwindow,NULL , ZLANG_OBJECT_string,NULL , ZLANG_OBJECT_string,NULL , ZLANG_OBJECT_string,NULL , ZLANG_OBJECT_string,NULL , ZLANG_OBJECT_int,NULL , ZLANG_OBJECT_string,NULL , ZLANG_OBJECT_string,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	return obj ;
}

